<html>
<head><meta charset="utf-8"><title>Is  there a `visit_stmt` function for ast::MutVisitor? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html">Is  there a `visit_stmt` function for ast::MutVisitor?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201457378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20%20there%20a%20%60visit_stmt%60%20function%20for%20ast%3A%3AMutVisitor%3F/near/201457378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html#201457378">(Jun 20 2020 at 02:17)</a>:</h4>
<p>I see <code>visit_expr</code> and <code>visit_block</code>, but no <code>visit_stmt</code>: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html</a></p>
<p>It's there for <code>Visitor</code> so I'm not sure why it's not here: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/visit/trait.Visitor.html#method.visit_stmt">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/visit/trait.Visitor.html#method.visit_stmt</a></p>



<a name="201457986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20%20there%20a%20%60visit_stmt%60%20function%20for%20ast%3A%3AMutVisitor%3F/near/201457986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html#201457986">(Jun 20 2020 at 02:37)</a>:</h4>
<p>really this whole thing would be much simpler if there were a <code>filter_stmt</code> on <code>MutVisitor</code></p>



<a name="201460337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20%20there%20a%20%60visit_stmt%60%20function%20for%20ast%3A%3AMutVisitor%3F/near/201460337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html#201460337">(Jun 20 2020 at 03:58)</a>:</h4>
<p>Ok it turns out <code>filter_stmt</code> isn't <em>quite</em> what I want - I want to flatten all statements and keep only those which are items.</p>



<a name="201460467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20%20there%20a%20%60visit_stmt%60%20function%20for%20ast%3A%3AMutVisitor%3F/near/201460467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html#201460467">(Jun 20 2020 at 04:01)</a>:</h4>
<p>I'm not sure what <code>.flatten()</code> would look like for an <code>ast::Stmt</code> because any expression can itself contain a nested statement, and items can have other nested items</p>



<a name="201460649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20%20there%20a%20%60visit_stmt%60%20function%20for%20ast%3A%3AMutVisitor%3F/near/201460649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html#201460649">(Jun 20 2020 at 04:07)</a>:</h4>
<p>I'm going to try going about this a different way that doesn't extensive changes to <code>MutVisitor</code></p>



<a name="201461207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20%20there%20a%20%60visit_stmt%60%20function%20for%20ast%3A%3AMutVisitor%3F/near/201461207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20.20there.20a.20.60visit_stmt.60.20function.20for.20ast.3A.3AMutVisitor.3F.html#201461207">(Jun 20 2020 at 04:25)</a>:</h4>
<p>might have gotten it, running <code>xpy test --stage 1 src/test/rustdoc*</code> now</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>